/**
 * 功能:
 * 作者:周逸健
 * 日期: 2023/10/27 9:31
 */
package com.cgnfz.crm.controller.exception;

import com.cgnfz.crm.entity.RestBean;
import jakarta.validation.ValidationException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class ValidationController {

    @ExceptionHandler(ValidationException.class)
    public RestBean<Void> validatException(ValidationException exception) {
        log.warn("Resolve [{}: {}]", exception.getClass().getName(), exception.getMessage());
        return RestBean.failure(400, "请求参数有误");
    }

}
